package de.coe.hendricjabs.friendmap;

import java.util.HashMap;

/**
 * @author Hendric
 * 
 */
public class Contact {

    private String mobilfunknummer;
    private String timestamp;
    private HashMap<String, String> coordinates;

    public Contact(String mobilfunknummer, String timestamp, String latitude, String longitude) {
        setMobilfunknummer(mobilfunknummer);
        this.timestamp = timestamp;
        this.coordinates = new HashMap<String, String>();
        coordinates.put("longitude", longitude);
        coordinates.put("latitude", latitude);
    }

    public Contact() {

    }

    /**
     * @return the mobilfunknummer
     */
    public String getMobilfunknummer() {
        return mobilfunknummer;
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
        Contact c = (Contact) obj;
        if (c.getCoordinates().get("longitude").equals(this.getCoordinates().get("longitude"))
                && c.getCoordinates().get("latitude").equals(this.getCoordinates().get("latitude"))
                && c.getMobilfunknummer().equals(this.getMobilfunknummer())
                && c.getTimestamp().equals(this.getTimestamp())) {
            return true;
        }
        return false;
    }

    /**
     * @param mobilfunknummer
     *            the mobilfunknummer to set
     */
    public void setMobilfunknummer(String mobilfunknummer) {
        if (mobilfunknummer.startsWith("+")) {
            this.mobilfunknummer = "0" + mobilfunknummer.substring(3);
        } else {
            this.mobilfunknummer = mobilfunknummer;
        }

    }

    /**
     * @return the timestamp
     */
    public String getTimestamp() {
        return timestamp;
    }

    /**
     * @param timestamp
     *            the timestamp to set
     */
    public void setTimestamp(String timestamp) {
        this.timestamp = timestamp;
    }

    /**
     * @return the coordinates
     */
    public HashMap<String, String> getCoordinates() {
        return coordinates;
    }

    /**
     * @param coordinates
     *            the coordinates to set
     */
    public void setCoordinates(HashMap<String, String> coordinates) {
        this.coordinates = coordinates;
    }

}
